package com.shd.edanpei.ui.adapter;

import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseViewHolder;
import com.shd.edanpei.R;
import com.shd.edanpei.base.BaseQuickImageAdapter;
import com.shd.edanpei.bean.SuggestBean;
import com.shd.edanpei.common.Constant;
import com.shd.edanpei.util.DateUtils;
import com.socks.library.KLog;

public class RecordAdapter extends BaseQuickImageAdapter<SuggestBean> {

    public RecordAdapter(Context context) {
        super(context, R.layout.iteam_opinion_record);
    }

    @Override
    protected void convert(BaseViewHolder helper, SuggestBean item) {

//
//        tvMore.setText(isGone ? "查看更多" : "收起更多");
//        ivArrow.setImageDrawable(ContextCompat.getDrawable(getContext(), isGone ? R.drawable.ic_pulldown : R.drawable.ic_pullup));

        final TextView tvContent = helper.getView(R.id.tv_content);
        final TextView tvMore = helper.getView(R.id.tv_more);

        helper.setText(R.id.tv_time, DateUtils.formatTime(item.getCreateTime(), Constant.Time.YYYY_MM_DD_HH_MM.getTime()));

        tvContent.setText(item.getContent());

        helper.getView(R.id.tv_more).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (tvMore.getText().toString().equals("查看更多")) {
                    tvContent.setMaxLines(20);
                    tvMore.setText("收起更多");
                } else {
                    tvContent.setMaxLines(2);
                    tvMore.setText("查看更多");
                }

            }
        });
    }
}
